package com.java.tutorials.jdk7.paths;

import java.nio.file.Path;
import java.nio.file.Paths;

/**
 * Created by xuzhike on 2016/1/27.
 * http://www.java2s.com/Code/Java/JDK-7/Gettherelativepathbetweentwopaths.htm
 * Get the relative path between two paths
 */
public class Gettherelativepathbetweentwopaths {
    public static void main(String[] args) {
        Path firstPath = Paths.get("music/A.mp3");
        Path secondPath = Paths.get("docs");

        System.out.println("From firstPath to secondPath: "
                + firstPath.relativize(secondPath));
        System.out.println("From secondPath to firstPath: "
                + secondPath.relativize(firstPath));
        System.out.println();

    }
}
